package geometria;

import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;

/**
 * 
 * Clase abstracta con comportamiento de figuras geometricas
 * 
 */
public abstract class Figura {

	protected Shape forma;
	protected Coordenada centro;
	protected Double rotacion;

	public boolean intersecta(Figura otro) {
		Area a1 = new Area(this.forma);
		Area a2 = new Area(otro.forma);
		a1.intersect(a2);
		return !a1.isEmpty();
	}

	public boolean contiene(Coordenada c) {
		return this.forma.contains(c.getX(), c.getY());
	}

	public Coordenada getCoordenadaCentral() {
		return this.centro;
	}

	public void rotar(Double rotacion) {
		AffineTransform transform = AffineTransform.getRotateInstance(rotacion,
				centro.getX(), centro.getY());
		this.forma = transform.createTransformedShape(this.forma);
		this.rotacion = rotacion;

	}
}
